//
// SoapTrace.Net - A soap message monitoring utility. 
//
// Copyright (C) 2005 Matthew Ward
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// Matthew Ward (mrward@users.sourceforge.net)


using NUnit.Framework;
using SoapTrace.Core.Formatters;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace SoapTrace.Tests.RichTextBoxFormatting
{
	/// <summary>
	/// Tests the <see cref="RichTextBoxFormatter"/> with a single
	/// line of coloured text.
	/// </summary>
	[ TestFixture ]
	public class SingleColourRichTextBoxTestFixture
	{
		RichTextBox m_RichTextBox;
		FormattedText m_FormattedText;
		Color m_TextColour = Color.Red;
		
		string m_Text = "Test";
		
		/// <summary>
		/// Initialises each test.
		/// </summary>
		[ SetUp ]
		public void Init( )
		{
			m_FormattedText = new FormattedText( m_TextColour );
			m_FormattedText.Append( m_Text );

			m_RichTextBox = new RichTextBox( );
			m_RichTextBox.WordWrap = false;
			m_RichTextBox.Multiline = true;
			
			RichTextBoxFormatter.Format( m_RichTextBox, m_FormattedText );
		}
		
		/// <summary>
		/// Check that the text has been added to the rich text box.
		/// </summary>
		[ Test ]
		public void RichTextBoxText( )
		{
			Assert.AreEqual( m_Text, m_RichTextBox.Text, 
			                "Text not added to rich text box." );
		}
		
		/// <summary>
		/// Checks that the text in the text box has the correct colour.
		/// </summary>
		[ Test ]
		public void RichTextBoxColour( )
		{
			m_RichTextBox.SelectAll( );
			
			Assert.AreEqual( m_TextColour, m_RichTextBox.SelectionColor, 
			                "Incorrect text colour." );
		}
		
		/// <summary>
		/// Check that after the formatting the text selection is correct.
		/// </summary>
		[ Test ]
		public void SelectionStart( )
		{
			Assert.AreEqual( 0, m_RichTextBox.SelectionStart, 
			                "Text selection start is wrong." );
		}
		
		/// <summary>
		/// Check that after the formatting the text selection is correct.
		/// </summary>
		[ Test ]
		public void SelectionLength( )
		{
			Assert.AreEqual( 0, m_RichTextBox.SelectionLength, 
			                "Text selection length is wrong." );			
		}
	}
}
